﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp16
{
    class Program
    {
        static void Main(string[] args)
        {
            string conString = "server=.;database=goodsInfo；uid=sa;pwd=123456";
            SqlConnection sqlConnection = new SqlConnection(conString);
            sqlConnection.Open();

            var sqlcommandString = "select * from Goods";
            SqlCommand sqlCommand = new SqlCommand(sqlcommandString, sqlConnection);

            var reader = sqlCommand.ExecuteReader();
            Console.WriteLine("{0}\t{1}\t{2}\t", "GoodsName", "GoodsPrice", "Adress");
            while (reader.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}\t", reader["GoodsName"], reader["GoodsPrice"], reader["Adress"]);

            }

            sqlConnection.Close();

        }
    }
}
